package com.ruoyi.information.controller.pc;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.information.domain.pc.CompanyNeed;
import com.ruoyi.information.service.pc.ICompanyNeedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业需求Controller
 *
 * @author ruoyi
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/need")
public class CompanyNeedController extends BaseController
{
    @Autowired
    private ICompanyNeedService companyNeedService;

    /**
     * 查询企业需求列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CompanyNeed companyNeed)
    {
        startPage();
        List<CompanyNeed> list = companyNeedService.selectCompanyNeedList(companyNeed);
        return getDataTable(list);
    }

    @GetMapping("/app")
    public AjaxResult app(CompanyNeed companyNeed)
    {
        startPage();
        List<CompanyNeed> list = companyNeedService.selectCompanyNeedList(companyNeed);
        return success(list);
    }

    /**
     * 获取企业需求详细信息
     */
    @GetMapping(value = "/getOne")
    public AjaxResult getInfo(@RequestParam("id") Long id)
    {
        return success(companyNeedService.selectCompanyNeedById(id));
    }

    /**
     * 新增企业需求
     */
    @PostMapping
    public AjaxResult add(@RequestBody CompanyNeed companyNeed)
    {
        companyNeed.setUserId(SecurityUtils.getUserId());
        return toAjax(companyNeedService.insertCompanyNeed(companyNeed));
    }

    /**
     * 修改企业需求
     */
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyNeed companyNeed)
    {
        return toAjax(companyNeedService.updateCompanyNeed(companyNeed));
    }

    /**
     * 删除企业需求
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyNeedService.deleteCompanyNeedByIds(ids));
    }
}
